﻿using System.Diagnostics;

namespace VSTalk.Engine.Core.Disco.Caps
{
    [DebuggerDisplay("Caps = {Node}#{Version}")]
    public class CapsInfo
    {
        public string Version { get; set; }
        public string Node { get; set; }
        public string Hash { get; set; }

        protected bool Equals(CapsInfo other)
        {
            return string.Equals(Version, other.Version) && string.Equals(Node, other.Node) && string.Equals(Hash, other.Hash);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != this.GetType()) return false;
            return Equals((CapsInfo) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = (Version != null ? Version.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Node != null ? Node.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Hash != null ? Hash.GetHashCode() : 0);
                return hashCode;
            }
        }

        public static bool operator ==(CapsInfo left, CapsInfo right)
        {
            return Equals(left, right);
        }

        public static bool operator !=(CapsInfo left, CapsInfo right)
        {
            return !Equals(left, right);
        }
    }
}